﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using XCI.Windows.Forms;
using DevExpress.XtraBars.Docking2010.Views.Widget;
using DevExpress.XtraBars.Docking2010;


namespace _8.test
{
    public partial class FrmSetting : FrmBase
    {
        private WidgetView widgetView;
        private Dictionary<string, Document> docs = new Dictionary<string, Document>();

        public FrmSetting(WidgetView widgetView)
        {
            InitializeComponent();
            this.widgetView = widgetView;
        }

        private void FrmSetting_Load(object sender, EventArgs e)
        {
            propertyGridControl1.SelectedObject = this.widgetView;

            foreach (Document document in widgetView.Documents)
            {
                docs[document.ControlName] = document;
                comboBoxEdit1.Properties.Items.Add(document.ControlName);
            }
        }

        private void BtnSave_Click(object sender, EventArgs e)
        {
            this.widgetView.SaveLayoutToXml("R:/view.xml");
        }

        private void BtnLoad_Click(object sender, EventArgs e)
        {
            this.widgetView.RestoreLayoutFromXml("R:/view.xml");
        }

        private void ComboBoxEdit1_SelectedValueChanged(object sender, EventArgs e)
        {
            propertyGridControl2.SelectedObject = docs[comboBoxEdit1.EditValue.ToString()];
            //propertyGridControl2.GetRowByFieldName("Footer").Visible = false;
            propertyGridControl2.GetRowByCaption("Custom Header Buttons").Visible = false;
        }

        private void PropertyGridControl2_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {

        }

        private void PropertyGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            //e.Row.Properties.FieldName
            //"LayoutMode"
            //e.Value
            //FlowLayout

        }
    }
}
